#include<iostream>
#include<cstring>
#include<cstdlib>
#include<cstdio>
using namespace std;
const int N = 1e5 + 10;
int prime[N];
int arr[110];
void fun()
{
	memset(prime, 1, sizeof(prime));
	prime[1] = 0;
	for (int i = 2; i * i <= N; i++) {
		for (int j = i * 2; j <= N; j+=i) {
			prime[j] = 0;
		}
	}
}
int main()
{
	int n;
	cin >> n;
	fun();
	for (int i = 0; i < n; i++) {
		cin >> arr[i];
		if (prime[arr[i]]) {
			cout << arr[i] << " ";
		}
	}
	return 0;
}